// 登录页面专用js文件
layui.use(['jquery', 'form'], function () {
    var layer = layui.layer;
    var form = layui.form;
    var $ = layui.jquery;

    //<button lay-submit lay-filter="filter">提交</button>
    form.on('submit(formLogin)', function (data) {
        layer.load(1);
        var field = data.field
        $.ajax({
            type: "post",
            url: "/admin/api_admin/login",
            data: {
                username: field.username,
                password: field.password,
            },
            dataType: "json",
            success: function (response) {
                console.log(response);
                if (response.code === 1) {
                    layer.msg(response.msg,{icon : 6});
                    location.href = redirect_url
                }else{
                    layer.msg(response.msg,{icon : 2});
                }
            },
            complete: function(){
                layer.closeAll('loading');
            }
        });

        return false;
    });
}); 